import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { OpenThrTouter, DelDataButton } from '../Common/options'
import { TestCategory, TestType } from '../Common/Conversion'

export const LabReportTemplates = async ({ OptionsEvent, oneData, Permission, actionRef }) => {
    const testCategoryUuid = await TestCategory()
    const testTypeUuid = await TestType()
    let dataList = {
        type: '试验检测参数列表',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([oneData.uuid])['getLabReportTemplateTestTypes'],
        pos: 'posLabReportTemplateTestTypesBatch',
        options: [
            Permission.findIndex(v => v.uuid === 'e14ad346-5f39-40a3-a2e8-a7982ee0186f') !== -1 && (
                <OpenThrTouter
                    title="添加参数"
                    type="primary"
                    icon="add"
                    modal="SelectModal"
                    OptionsEvent={OptionsEvent}
                    other={{
                        page: 'LabReportTemplates',
                        actionRef,
                        Permission,
                        twoData: oneData,
                    }}
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'labReportTemplateUuid',
                title: '编号',
                valueType: 'hidden',
                hidden: true,
                hideInTable: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'testCategoryUuid',
                title: '试验类别',
                valueType: 'select',
                hideInSearch: true,
                valueEnum: testCategoryUuid,
            },
            {
                dataIndex: 'testTypeUuid',
                title: '试验参数',
                valueType: 'select',
                hideInSearch: true,
                valueEnum: testTypeUuid,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 100,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '55e826ff-f48c-42ef-aa4c-8481d7c439e9') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url="LabReportTemplateTestTypes"
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return dataList
}
